﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PMESqlOperator
{
    public class SourceQuantityOperator
    {

        public Id_Name_Param<int,string>[] GetQuantities()
        {
            using (var entity = new PMESqlOperator.ION_DataEntities()) 
            {
                entity.Database.Connection.Open();
                var res = from c in entity.Quantity.ToArray() select new Id_Name_Param<int, string>() { Id = c.ID, Name = c.Name };
                return res.ToArray();
            }
            //return FunctionLib.DBOperator.InfluxDBClient.CreatDBClient().GetTags("QuantityID").ToArray();
        }
        public Id_Name_Param<int, string>[] GetSources()
        {
            using (var entity = new PMESqlOperator.ION_DataEntities())
            {
                entity.Database.Connection.Open();
                var res = from c in entity.Source.ToArray() select new Id_Name_Param<int, string>() { Id = c.ID, Name = c.Name };
                return res.ToArray();
            }
            //return FunctionLib.DBOperator.InfluxDBClient.CreatDBClient().GetTags("SourceID").ToArray();
        }
    }
    public class Id_Name_Param<T1,T2>
    {
        T1 id;
        T2 name;

        public T1 Id { get => id; set => id = value; }
        public T2 Name { get => name; set => name = value; }
    }
}
